package com.shaoshaohuo.app.ui;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ListView;

import com.shaoshaohuo.app.R;
import com.shaoshaohuo.app.constant.ExtraName;
import com.shaoshaohuo.app.entity.Province;
import com.shaoshaohuo.app.view.TopbarView;

@Deprecated
public class SelectProvinceActivity extends BaseActivity {

	private TopbarView mTopbarView;

	private ListView mCityListview;

    protected Province province;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_select_city);
		initView();
		setUpView();
	}

	private void initView() {
		mTopbarView = (TopbarView) this.findViewById(R.id.topbar);
		mCityListview = (ListView) this.findViewById(R.id.listview_city_list);
	}

	private void setUpView() {
		mTopbarView.setCenterText("选择省份");
		mTopbarView.setLeftView(true, true);

//		List<Province> findAllProvince = DaoUtils.findAllProvince();
//		ProvinceListAdapter<Province> mAdapter = new ProvinceListAdapter<>(this, findAllProvince, false);
//		mCityListview.setAdapter(mAdapter);
//		mCityListview.setOnItemClickListener(new OnItemClickListener() {
//
//			@Override
//			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//			    province = (Province) parent.getItemAtPosition(position);
//			    Intent intent = new Intent(SelectProvinceActivity.this,SelectCityActivity.class);
//			    intent.putExtra("proid", province.getProid());
//			    startActivityForResult(intent, 0);
//			}
//		});
	}

	@Override
	protected void onActivityResult(int arg0, int arg1, Intent arg2) {
	    super.onActivityResult(arg0, arg1, arg2);
	    if(arg1 == RESULT_OK && arg2 != null){
	        arg2.putExtra(ExtraName.province, province);
	        setResult(RESULT_OK, arg2);
	        finish();
	    }
	}
	
}
